package com.ccx.demo.config.convert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.utils.util.Range;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 自定义入参转换
 *
 * @author 谢长春 2020-10-27
 */
@Component
public class StringToRangeBigDecimalConverter implements Converter<String, Range<BigDecimal>> {
    @Override
    public Range<BigDecimal> convert(String value) {
        return JSON.parseObject(value, new TypeReference<Range<BigDecimal>>() {
        });
    }
}
